package cn.unknowpupil.sms.service.impl;

import cn.unknowpupil.common.core.resopnse.ResultResponse;
import cn.unknowpupil.sms.configure.AliYunEnum;
import cn.unknowpupil.sms.service.IAliyunSmsService;
import cn.unknowpupil.sms.utils.AliYunSmsUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;


/**
 * Created at 2020/10/21 by w10g <br>
 * Initialize AliyunSmsServiceImpl ... <br>
 * 模板配置实现类
 *
 * @author unknowpupil
 * @since 0.0.1
 */
@Slf4j
@Service
public class AliyunSmsServiceImpl implements IAliyunSmsService {


    @Override
    public void sendSmsNotice(String[] phoneArray, String circleName) {
        Map map = new HashMap();
        map.put("circle", circleName);
        AliYunSmsUtil.sendSms(phoneArray, map, AliYunEnum.NOTICE_PHONE.getValue());
    }


    @Override
    public void sendSmsNotice(String[] phoneArray, String circleName, String title) {
        log.info("[短信发送] 短信发送人员={}",phoneArray);
        Map map = new HashMap();
        map.put("circle", circleName);
        map.put("title", title);
        AliYunSmsUtil.sendSms(phoneArray, map, AliYunEnum.NOTICE_PHONE_NEW.getValue());
    }

    @Override
    public ResultResponse sendBingSms(String phone, String val) {
        Map map = new HashMap();
        map.put("code", val);
        return AliYunSmsUtil.sendSms(phone, map, AliYunEnum.BING_PHONE.getValue());
    }

    @Override
    public ResultResponse sendLoginSms(String phone, String val) {
        Map map = new HashMap();
        map.put("code", val);
        return AliYunSmsUtil.sendSms(phone, map, AliYunEnum.LOGIN_PHONE.getValue());
    }
}

